@echo off

set BUILDTARGETDIR=%BuildTargetRoot%\%BuildType%\

call vars.cmd

cscript /nologo %BuildRoot%\tools\setup\createlicense.vbs

REM Wrap the Managed custom action in to Unmanaged

REM Copy the custom Action files to temp directory becuase the MakeSfxCA.exe required absolute path and %temp% resolved to absolute path
ECHO COPYING FILES
xcopy %BUILDTARGETDIR%TridentManagedCustomActions.dll %temp% /r /q /y

echo %BUILDTARGETDIR%\TridentManagedCustomActions.dll

echo %BuildTarget%
call %BuildRoot%\public\ext\wix3\SDK\MakeSfxCA.exe %Temp%\TridentManagedCustomActions.CA.dll %BuildRoot%\public\ext\wix3\SDK\%BuildTarget%\sfxca.dll %temp%\TridentManagedCustomActions.dll %BuildRoot%\public\ext\wix3\SDK\Microsoft.Deployment.WindowsInstaller.dll

xcopy %temp%\TridentManagedCustomActions.CA.dll %BUILDTARGETDIR% /r /q /y

call %BuildRoot%\public\ext\wix2\candle.exe .\WixCommon\mondo\WixUI_Mondo_trident.wxs .\WixCommon\BrowseDlg.wxs .\WixCommon\CancelDlg.wxs .\WixCommon\Common.wxs .\WixCommon\TridentSQLUI.wxs .\WixCommon\CustomizeDlg.wxs .\WixCommon\DiskCostDlg.wxs .\WixCommon\ErrorDlg.wxs .\WixCommon\ErrorProgressText.wxs .\WixCommon\ExitDialog.wxs .\WixCommon\FatalError.wxs .\WixCommon\FilesInUse.wxs .\WixCommon\InstallDirDlg.wxs .\WixCommon\LicenseAgreementDlg.wxs .\WixCommon\MaintenanceTypeDlg.wxs .\WixCommon\MaintenanceWelcomeDlg.wxs .\WixCommon\MsiRMFilesInUse.wxs .\WixCommon\OutOfDiskDlg.wxs .\WixCommon\OutOfRbDiskDlg.wxs .\WixCommon\PrepareDlg.wxs .\WixCommon\ProgressDlg.wxs .\WixCommon\ResumeDlg.wxs .\WixCommon\SetupTypeDlg.wxs .\WixCommon\UserExit.wxs .\WixCommon\VerifyReadyDlg.wxs .\WixCommon\WaitForCostingDlg.wxs .\WixCommon\WelcomeDlg.wxs .\WixCommon\WelcomeEulaDlg.wxs .\WixCommon\OneClickInstallDlg.wxs .\WixCommon\ComputerSelectDlg.wxs .\WixCommon\HPCDetailsDlg.wxs .\WixCommon\ServiceDetailsDlg.wxs

set BUILDERR=%ERRORLEVEL%
IF %BUILDERR% NEQ 0 GOTO ERROR

call %BuildRoot%\public\ext\wix2\lit.exe -out .\WixCommon\WixUI_Mondo_trident.wixlib WixUI_Mondo_trident.wixobj BrowseDlg.wixobj CancelDlg.wixobj Common.wixobj TridentSQLUI.wixobj CustomizeDlg.wixobj DiskCostDlg.wixobj ErrorDlg.wixobj ErrorProgressText.wixobj ExitDialog.wixobj FatalError.wixobj FilesInUse.wixobj InstallDirDlg.wixobj LicenseAgreementDlg.wixobj MaintenanceTypeDlg.wixobj MaintenanceWelcomeDlg.wixobj MsiRMFilesInUse.wixobj OutOfDiskDlg.wixobj OutOfRbDiskDlg.wixobj PrepareDlg.wixobj ProgressDlg.wixobj ResumeDlg.wixobj SetupTypeDlg.wixobj UserExit.wixobj VerifyReadyDlg.wixobj WaitForCostingDlg.wixobj WelcomeDlg.wixobj WelcomeEulaDlg.wixobj ComputerSelectDlg.wixobj OneClickInstallDlg.wixobj HPCDetailsDlg.wixobj ServiceDetailsDlg.wixobj

set BUILDERR=%ERRORLEVEL%
IF %BUILDERR% NEQ 0 GOTO ERROR

call %BuildRoot%\public\ext\wix2\candle.exe .\TridentProduct.wxs TridentComposer.wxs TridentManagementStudio.wxs TridentExecutor.wxs TridentHPCUpdate.wxs TridentStandaloneWorkflowApplication.wxs TridentProvenance.wxs TridentSQLScripts.wxs TridentWebServiceProvider.wxs TridentCommon.wxs TridentHPCPack.wxs

set BUILDERR=%ERRORLEVEL%
IF %BUILDERR% NEQ 0 GOTO ERROR

call %BuildRoot%\public\ext\wix2\light.exe -out trident.msi .\WixCommon\WixUI_Mondo_trident.wixlib -loc %LOCTEXTXML% TridentManagementStudio.wixobj TridentExecutor.wixobj TridentComposer.wixobj TridentHPCUpdate.wixobj TridentStandaloneWorkflowApplication.wixobj TridentProvenance.wixobj TridentSQLScripts.wixobj TridentWebServiceProvider.wixobj TridentCommon.wixobj .\TridentProduct.wixobj TridentHPCPack.wixobj %BuildRoot%\public\ext\wix2\sca.wixlib %BuildRoot%\public\ext\wix2\wixca.wixlib

set BUILDERR=%ERRORLEVEL%
IF %BUILDERR% NEQ 0 GOTO ERROR

rem delete all wixobj files
del *.wixobj

goto DONE

:ERROR
echo Error in building msi

:DONE